VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} FileSelect 
   Caption         =   "FileSelect"
   ClientHeight    =   4785
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5100
   OleObjectBlob   =   "FileSelect.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "FileSelect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Public hConnect As Long
'ini file local
Private TempFold As String
Dim ServerIP As String
Dim UserName As String
Dim UserPassWord As String

Dim StatesPath As String
Private Sub MyList_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    
    Dim strFileLocal As String, strFileRemote As String
    Dim dwType As Integer
    Dim bRet As Boolean
    strFileRemote = MyList.list(MyList.ListIndex)
    'local
    strFileLocal = TempFold + strFileRemote
    'get file to local
    bRet = GetFTPFile(hConnect, iniPath + strFileRemote, TempFold + strFileRemote)
    If bRet = False Then
        MsgBox "Can not download file!", vbOKOnly + vbCritical, "Error!"
    End If
    MyList.Clear
    FTPClose hConnect
    myDownLoadFile = strFileLocal
    downloadFlag = True
    'get ini path and name
    iniPath = strFileLocal
    Unload FileSelect
    'FileSelect.Hide
    
End Sub


Private Sub UserForm_Initialize()
    
    Dim FTPFile As New CIniFile

    Dim allFile() As String
    
    Call FTPFile.SpecifyIni("D:\ATE\Config\webConfig.ini")
    ServerIP = FTPFile.ReadString("FTP", "ServerIP", 20)
    UserName = FTPFile.ReadString("FTP", "UserName", 20)
    UserPassWord = FTPFile.ReadString("FTP", "UserPassWord", 20)
    TempFold = FTPFile.ReadString("FTP", "TempFold", 30)
    iniPath = FTPFile.ReadString("Path", "Config", 60)
    StatesPath = FTPFile.ReadString("Path", "States", 60)
    Dim fileString() As String
    hConnect = FTPOpen(ServerIP, UserName, UserPassWord, allFile, iniPath)
    For i = 0 To UBound(allFile)
        MyList.AddItem allFile(i)
    Next i
    
End Sub


Sub IniFileCopy()
    
    Dim FTPFile As New CIniFile
    Dim ServerIP As String
    Dim UserName As String
    Dim UserPassWord As String
    Dim iniPath As String
    Dim StatesPath As String
    Dim allFile() As String
    
    Call FTPFile.SpecifyIni("D:\ATE\Config\webConfig.ini")
    ServerIP = FTPFile.ReadString("FTP", "ServerIP", 20)
    UserName = FTPFile.ReadString("FTP", "UserName", 20)
    UserPassWord = FTPFile.ReadString("FTP", "UserPassWord", 20)
    iniPath = FTPFile.ReadString("Path", "Config", 60)
    Dim fileString() As String
    hConnect = FTPOpen(ServerIP, UserName, UserPassWord, allFile, iniPath)
    For i = 0 To UBound(fileString)
    FileCopy iniPath + fileString(i), "D:\007549\ini\"
    Next
    FTPClose hConnect
    
End Sub

Sub StatesFileCopy()

    Dim FTPFile As New CIniFile
    Dim ServerIP As String
    Dim UserName As String
    Dim UserPassWord As String
    Dim iniPath As String
    Dim StatesPath As String
    Dim allFile() As String
    
    Call FTPFile.SpecifyIni("D:\ATE\Config\webConfig.ini")
    ServerIP = FTPFile.ReadString("FTP", "ServerIP", 20)
    UserName = FTPFile.ReadString("FTP", "UserName", 20)
    UserPassWord = FTPFile.ReadString("FTP", "UserPassWord", 20)
    StatesPath = FTPFile.ReadString("Path", "States", 60)
    Dim fileString() As String
    hConnect = FTPOpen(ServerIP, UserName, UserPassWord, allFile, StatesPath)
    For i = 0 To UBound(fileString)
    FileCopy iniPath + fileString(i), "D:\007549\states\"
    Next
    FTPClose hConnect

End Sub
